<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="renderer" content="webkit|ie-comp|ie-stand" />  
    <meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
    <meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1">
    <meta name="apple-mobile-web-app-status-bar-style" content="black">
    <meta name="apple-mobile-web-app-capable" content="yes">
    <meta name="format-detection" content="telephone=no">
    <link rel="stylesheet" type="text/css" href="layui/css/layui.css" media="all">
    <link rel="stylesheet" type="text/css" href="css/index.css"/>
    
</head>
<body>
<section class="layui-larry-box">
    <!--设备监控-->
    <div class="larry-personal">
        <div class="layui-tab">
            <blockquote class="layui-elem-quote mylog-info-tit" style="background: #fff;">
                <ul class="handle-box" id="conditions">
                    <li class="handle-item"><span class="layui-form-label">条件查询：</span>
                        <div class="layui-input-inline">
                            <input type="text" autocomplete="off" placeholder="请输入搜索条件" class="layui-input"
                                   v-model="deviceName">
                        </div>
                        <button class="layui-btn mgl-20" @click="getDeviceList">查询</button>
                    </li>
                    <li class="handle-item" style="padding-top: 10px;">
                        <span class="layui-form-label">设备类型：</span>
                        <div class="btn_block" style="height: 38px; line-height: 38px; ">
                        	<label class="layui-btn-block">不限<input type="radio" name="sex1" value="-1" style="display: none;" v-model="deviceType" @change="getDeviceList"></label>
                        	<label class="layui-btn-none">GPRS<input type="radio" name="sex1" value="0" style="display: none;" v-model="deviceType" @change="getDeviceList"></label>
                        	<label class="layui-btn-none">WIFI<input type="radio" name="sex1" value="1" style="display: none;" v-model="deviceType" @change="getDeviceList"></label>
                        </div>
                    </li>
                    <li class="handle-item">
                        <span class="layui-form-label">应用场景：</span>
                        <div style="height: 38px; line-height: 38px;" class="btn_block">
                            <label class="layui-btn-block">不限<input type="radio" name="scene_id" value="-1" style="display: none;" v-model="sceneId" @change="getDeviceList"></label>
                            <label class="layui-btn-none">常温库<input type="radio" name="scene_id" value="1" style="display: none;" v-model="sceneId" @change="getDeviceList"></label>
                            <label class="layui-btn-none">阴凉库<input type="radio" name="scene_id" value="2" style="display: none;" v-model="sceneId" @change="getDeviceList"></label>
                            <label class="layui-btn-none">冷藏库<input type="radio" name="scene_id" value="3" style="display: none;" v-model="sceneId" @change="getDeviceList"></label>
                            <label class="layui-btn-none">冷藏车<input type="radio" name="scene_id" value="4" style="display: none;" v-model="sceneId" @change="getDeviceList"></label>
                            <label class="layui-btn-none">冷藏箱<input type="radio" name="scene_id" value="5" style="display: none;" v-model="sceneId" @change="getDeviceList"></label>
                            <label class="layui-btn-none">医用冰箱<input type="radio" name="scene_id" value="6" style="display: none;" v-model="sceneId" @change="getDeviceList"></label>
                            <label class="layui-btn-none">其他<input type="radio" name="scene_id" value="0" style="display: none;" v-model="sceneId" @change="getDeviceList"></label>
                        </div>

                    </li>
                    <li class="handle-item">
                        <span class="layui-form-label">设备状态：</span>
                        <div style="height: 38px; line-height: 38px;" class="btn_block">
                            <label class="layui-btn-block">不限<input type="radio" name="sex3" value="-1" style="display: none;" v-model="deviceState" @change="getDeviceList"></label>
                            <label class="layui-btn-none">正常<input type="radio" name="sex3" value="2" style="display: none;" v-model="deviceState" @change="getDeviceList"></label>
                            <label class="layui-btn-none">超限<input type="radio" name="sex3" value="1" style="display: none;" v-model="deviceState" @change="getDeviceList"></label>
                            <label class="layui-btn-none">异常<input type="radio" name="sex3" value="0" style="display: none;" v-model="deviceState" @change="getDeviceList"></label>
                            <label class="layui-btn-none">离线<input type="radio" name="sex3" value="3" style="display: none;" v-model="deviceState" @change="getDeviceList"></label>
                        </div>
                    </li>
                </ul>
            </blockquote>
            <!--<div class="layui-clear">
		       <div class="tableTools fr"></div>
		    </div>-->
            <div class="layui-tab-item layui-field-box layui-show" v-run="loadTable()">
                <table class="table-box table-sort" id="deviceTable" lay-even="" lay-skin="nob" >

                </table>
            </div>
        </div>
    </div>
</section>
<script type="text/javascript" src="layui/layui.js"></script>
<script type="text/javascript" src="js/common.js"></script>
<script type="text/javascript" src="js/monitoring.js"></script>
<script type="text/javascript" src="js/vue/vue.js"></script>
<script src="//cdn.bootcss.com/jquery/3.2.0/jquery.js"></script>
<script src="//cdn.bootcss.com/vue-resource/1.2.1/vue-resource.js"></script>
<script>

    var vue = new Vue({
                el: '#conditions',
                data: {
                    deviceName: "",
                    deviceType: -1,
                    sceneId: -1,
                    deviceState: -1,
                    monitorScene: [
                    ],
                },
                mounted: function () {
                    this.$nextTick(function () {
                        var token=new Object();
                        token.accessToken=accessToken;
                        this.$http.get(url + "/ic-iot/users/" + adminId + "/devices/scenes",
                                { headers:token}).then(function (response) {
                            var res = response.body;
                            if (res.code == 1) {
                                this.monitorScene = res.result;
                            }
                        }).catch(function(response) {
                            console.log(response)
                        });
                    });
                },
                methods: {
                    getDeviceList:function () {
                        var params = new Object();
                        params.pageSize=999;
                        params.currentPage=1;
                        if(this.deviceName!="")
                                params.deviceName=this.deviceName;
                        if(this.deviceType!=-1)
                                params.deviceType=this.deviceType;
                        if(this.deviceState!=-1)
                                params.deviceState=this.deviceState;
                        if(this.sceneId!=-1)
                                params.sceneId=this.sceneId;
                        var token=new Object();
                        token.accessToken=accessToken;
                        this.$http.get(url + "/ic-iot/admin/" + adminId + "/devicesWithRecords",
                                { params: params ,headers:token}).then(function (response) {
                            var res = response.body;
                            if (res.code == 1) {
                                var result = res.result;
                                $('#deviceTable').dataTable().fnClearTable();
                                if(result.length!=0)
                                    $('#deviceTable').dataTable().fnAddData(result);
                            }
                        }).catch(function(response) {
                            console.log(response)
                        });
                    }
                }
            }
    );

</script>
</body>
</html>